const app = getApp()

Page({
  data: {
    tabs: [
      {
        id: 0,
        value: "进行中",
        isActive: true
      },
      {
        id: 1,
        value: "已完成",
        isActive: false
      }
    ],
    dealList: [],
    completeList:[]
  },

  handleItemChange(e) {
    // console.log(e)
    // 获取被点击的标题索引
    const {index} = e.detail;
    // 修改原数组
    let {tabs} = this.data;
    tabs.forEach((v, i) => i === index? v.isActive = true : v.isActive = false);
    // 赋值到data中
    this.setData({
      tabs
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.sendGetRequest('/community/complain/', (res) => {
      console.log(res)
      if(res.code == 200) {
        let dealList = []
        let completeList = []
        res.data.forEach(item => {
          if(item.status == '处理完成') {
            completeList.push(item)
          } else {
            dealList.push(item)
          }
        })
        this.setData({
          dealList,
          completeList
        })
      }
    })
  }
})